﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AGRTraining.za.co.agrtraining.model;

namespace AGRTraining.za.co.agrtraining.services.impl
{
    public class PlacementServiceImpl:IPlacementService
    {
        private AGRModelContainer agrDb = new AGRModelContainer();
        public IEnumerable<Student> viewAllQualifyingStudents(string placementCode)
        {
            var placeType = from place in agrDb.Placements1
                            where place.PlacementCode == placementCode
                            select place.PlacementType;
            var studs = from stud in agrDb.Students
                        from factStudCrs in agrDb.FactStudentCourses
                        from crs in agrDb.Courses
                        where crs.CourseName == placeType.ToString()
                        where crs.CourseCode == factStudCrs.CourseCode
                        where factStudCrs.StudentCode == stud.StudentCode
                        select stud;
            return studs;
        }
    }
}